<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">主页</a>
        <a><cite lay-href="/user/list">用户列表</cite></a>
        <a><cite>添加用户</cite></a>
    </div>
</div>
<style>
    .layui-form-label {
        width:15% !important;
        margin-left:1%;
    }
    .layui-input-inline {
        width: 33% !important;
    }
</style>
<div class="layui-fluid">
    <div class="layui-card">
        <form class="layui-form layui-form-pane">
            <div class="layui-tab layui-tab-brief">
                <ul class="layui-tab-title">
                    <li class="layui-this">基本信息 <span style="color: red; font-size: 12px;"> *为必填项</span></li>
                </ul>
                <input type="hidden" name="codePath" id="codePath" />
                <div class="layui-tab-content">
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span style="color: red;">* </span>登陆用户名</label>
                        <div class="layui-input-inline">
                            <input type="text" id="username" name="username" lay-verify="required" placeholder="请输入登陆用户名" autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label"><span style="color: red;">* </span>登陆密码</label>
                        <div class="layui-input-inline">
                            <input type="password" id="password" name="password" lay-verify="required" placeholder="请输入登陆密码" value="" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span style="color: red;">* </span>真实姓名</label>
                        <div class="layui-input-inline">
                            <input type="text" id="realName" name="realName" lay-verify="required" placeholder="请输入真实姓名" autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label"><span style="color: red;">* </span>账号类型</label>
                        <div class="layui-input-inline">
	                        <select name="type" id="type" required lay-search="">
                                <option value="4">子账号</option>
                                <option value="2">代理码商</option>
                                <option value="1">会员</option>
		                    </select>
	                    </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span style="color: red;">* </span>保证金</label>
                        <div class="layui-input-inline">
                            <input type="text" id="deposit" name="deposit" lay-verify="required|number" placeholder="请输入保证金,收款金额不能大于保证金" autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label"><span style="color: red;">* </span>费率(%)</label>
                        <div class="layui-input-inline">
                            <input type="text" id="rate" name="rate" lay-verify="required|number" placeholder="请输入用户费率,百分比" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span style="color: red;">* </span>每天收款次数</label>
                        <div class="layui-input-inline">
                            <input type="text" id="dayMaxNum" name="dayMaxNum" lay-verify="required|number" placeholder="请输入每天允许收款次数" autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label"><span style="color: red;">* </span>每天收款金额(元)</label>
                        <div class="layui-input-inline">
                            <input type="text" id="dayMaxAmount" name="dayMaxAmount" lay-verify="required|number" placeholder="每天允许收款金额,单位元" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">邮箱</label>
                        <div class="layui-input-inline">
                            <input type="text" id="email" name="email" placeholder="请输入邮箱" autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label">手机号</label>
                        <div class="layui-input-inline">
                            <input type="text" id="mobile" name="mobile" placeholder="请输入手机号" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                    	<label class="layui-form-label">备注信息</label>
                        <div class="layui-input-block">
                            <input type="text" id="remark" name="remark" placeholder="请输入备注信息" autocomplete="off" style="width: 92%" class="layui-input" />
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block" style="padding-bottom: 20px;">
                        <button type="button" class="layui-btn" lay-submit="" lay-filter="addBtn">保存</button>
                        <a class="layui-btn" lay-href="/user/list">返回</a>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<script>
    layui.use(['admin', 'form', 'upload'],function(){
        var form = layui.form
        ,$ = layui.$
        ,admin = layui.admin
        ,element = layui.element
        ,layer = layui.layer ;

        element.render('breadcrumb', 'breadcrumb');

        admin.req({
            type: 'get',
            url: layui.setter.baseUrl + '/getConfig',
            success: function(res){
                if(res.code == 0){
                    $('#dayMaxNum').val(res.data.userDayNumDefault);
                    $('#dayMaxAmount').val(res.data.userDayMaxAmountDefault);
                    form.render();
                }
            }
        });

        form.on('submit(addBtn)', function(data) {
            if(!$("#codePath")){
                layer.alert("请先上传二维码");
                return ;
            }
            admin.req({
                type: "POST",
                url: layui.setter.baseUrl + '/user/add',
                data: data.field,
                success: function(res){
                    if(res.code == 0) {
                        layer.alert(res.msg, {title: "提示"}, function(index){
                          layer.close(index);
                          location.href = layui.setter.baseLocal + 'user/list';
                        });
                    }
                }
            });
        });
        form.render();
    })
</script>